package v1beta1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// AttachVolumeSpec defines the desired state of volume attachment to server
type AttachVolumeSpec struct {
	// provider secret
	ProviderRef ProviderRef `json:"providerRef,omitempty"`
	//+optional
	ServerRef string `json:"serverRef,omitempty"`
	//+optional
	VolumeRef string `json:"volumeRef,omitempty"`
	// 必填：云服务器ID
	ServerId string `json:"serverId,omitempty"`
	// 云服务器挂载信息
	VolumeAttachment VolumeAttachment `json:"volumeAttachment,omitempty"`
}

type VolumeAttachment struct {
	// 必填：待挂载磁盘的磁盘ID，UUID格式
	VolumeId string `json:"volumeId,omitempty"`
	// 磁盘挂载点
	Device string `json:"device,omitempty"`
	// 云硬盘类型：该字段于dry_run为true并且volumeId不存在时有效且为必选字段。
	VolumeType string `json:"volume_type,omitempty"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:resource:shortName=attachvolume
// +kubebuilder:subresource:status

// AttachVolume is the Schema for the c API
type AttachVolume struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              AttachVolumeSpec `json:"spec,omitempty"`
	// status of AttachVolume
	Status CloudStatus `json:"status,omitempty"`
}

type CloudStatus struct {
	// returned volume information
	Info VolumeInfo `json:"info,omitempty" protobuf:"bytes,5,opt,name=info"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// AttachVolumeList contains a list of AttachVolume item
type AttachVolumeList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []AttachVolume `json:"items"`
}
